package com.niiwoo.civet.trade.configuration;

import com.niiwoo.civet.trade.constant.RabbitConstant;
import com.niiwoo.civet.trade.constant.TradeFanoutRabbitConstant;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by dell on 2017/12/15.
 */
@Configuration
public class InvestEventMqConfiguration {
	//**********************
	//投资事件mq配置
	//**********************
	@Bean
	public Exchange investEventExchange() {
		return new DirectExchange(RabbitConstant.Exchange.INVEST_EVENT, true, true);
	}

	@Bean
	public Queue investEventQueue() {
		return new Queue(RabbitConstant.Queue.INVEST_EVENT, true);
	}

	@Bean
	public Binding investEventBinding() {
		return BindingBuilder.bind(investEventQueue()).to(investEventExchange()).with(RabbitConstant.RoutingKey.INVEST_EVENT).noargs();
	}
	
	// 投资回款
    @Bean
    public FanoutExchange investReturnAmountFanoutExchange() {
        return new FanoutExchange(TradeFanoutRabbitConstant.Exchange.INVEST_RETURN_AMOUNT_FANOUT_EXCHANGE, true, true);
    }	
}
